function [a,b] = lsline(X,Y)
% [a,b] = lsline(X,Y)
% Construct the least squares line.
% X is an 1xn abscissa vector, input.
% Y is an 1xn ordinate vector, input.
% a is a coefficient; y = ax+b, output.
% b is a coefficient; y = ax+b, output.
xmean = mean(X);
ymean = mean(Y);
sumx2 = (X-xmean)*(X-xmean)';
sumxy = (Y-ymean)*(X-xmean)';
a = sumxy/sumx2;
b = ymean-a*xmean;
